;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;                      Basic Customization                         ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (setq visible-bell t)
 
;; Arduino
(load-file "/home/christian/Documents/arduino/Installation/emacs_conf/arduino-mode.el")

;; http://sametmax.com/lencoding-en-python-une-bonne-fois-pour-toute/
;; Le fichier dans lequel vous écrivez votre code est dans un encoding qui dépend de votre éditeur !!
;; Utiliser par défaut UTF8, qui gére le plus
;; Si vous ne savez pas dans quel encoding est votre code, vous ne pouvez pas manipuler du texte et garantir l’absence de bug.
;; Vous ne POUVEZ PAS.

(set-language-environment 'utf-8)

;; ---------------------------------------------------------------------------
 ;; set up the function keys to do common tasks to reduce Emacs pinky
 ;; ---------------------------------------------------------------------------
 
 (global-set-key [f1] 'help-command)                      ; F1 = help
 (global-set-key [f2] 'save-buffer)                       ; F2 = save
 (global-set-key [f3] 'indent-region)                     ; F3 = Tab
 (global-set-key [f4] 'untabify)                          ; F4 = Ã´te les Tab et remplace par space
 (global-set-key [f5] 'shell)                             ; F5 = shell
 (global-set-key [f6] 'run-octave)                        ; F6 = octave
 
 (global-set-key [f9] 'compile)                           ; F9 = compile
 (global-set-key [f10] 'gdb)                              ; F10 = debugger gdb
 
 ;; ---------------------------------------------------------------------------
 ;; Gestion et affichage corrects des accents dans le shell
 ;; ---------------------------------------------------------------------------
 (defadvice shell (before advice-utf-shell activate)
   (set-default-coding-systems 'utf-8))
 (ad-activate 'shell)
 

;; ---------------------------------------------------------------------------
 ;; Kill Ctrl-s for search and it for save
 ;; ---------------------------------------------------------------------------
  (define-key isearch-mode-map "\C-s" nil)
  (global-set-key "\C-s" 'save-buffer)                     ; Ctrl-s = save
 

;; ---------------------------------------------------------------------------
 ;; ADD Ctrl-f
 ;; ---------------------------------------------------------------------------
  (define-key global-map [\C-f]   'isearch-forward)         ; Search
  (global-set-key "\C-f" 'isearch-forward)                 ; Search
  (define-key isearch-mode-map "\C-f" 'isearch-repeat-forward)
 
 ;; ---------------------------------------------------------------------------
 ;; This makes the buffer scroll by only a single line when the up or
 ;; down cursor keys push the cursor (tool-bar-mode) outside the
 ;; buffer. The standard emacs behaviour is to reposition the cursor in
 ;; the center of the screen, but this can make the scrolling confusing
 ;; ---------------------------------------------------------------------------
  (setq scroll-step 1)
  (setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))
  (setq mouse-wheel-progressive-speed nil)


;; ---------------------------------------------------------------------------
 ;; Switch between windows
 ;; ---------------------------------------------------------------------------        
  (define-key global-map [\C-tab]   'other-window)        
 

;; ---------------------------------------------------------------------------
 ;; Octave
 ;; ---------------------------------------------------------------------------        
  (autoload 'octave-mode "octave-mod" nil t)
  (setq auto-mode-alist
        (cons '(".m$" . octave-mode) auto-mode-alist))
 
 

(add-hook 'octave-mode-hook
            (lambda ()
              (abbrev-mode 1)
              (auto-fill-mode 1)
              (if (eq window-system 'x)
                  (font-lock-mode 1))))
  (autoload 'run-octave "octave-inf" nil t)
 
 

;; ---------------------------------------------------------------------------
 ;; Wiki
 ;; ---------------------------------------------------------------------------        
  (autoload 'wikipedia-mode "wikipedia-mode.el"
  "Major mode for editing documents in Wikipedia markup." t)
 
 

(add-to-list 'auto-mode-alist
  '(".wiki'" . wikipedia-mode))
 
 

(autoload 'longlines-mode "longlines.el"
  "Minor mode for editing long lines." t)
 
 

;; ---------------------------------------------------------------------------
 ;; Remove the binding of \C-x \C-c, which normally exits emacs.
 ;; ---------------------------------------------------------------------------        
  (global-set-key "\C-x \C-c" 'nil)
 
 

;; ========= Set colours ==========
 
 

;; Set cursor and mouse-pointer colours
  (set-cursor-color "yellow")
 
 

;; Set region background colour
  (set-face-background 'region "grey40")
 
 

;; Set emacs background colour
  (set-background-color "grey5")
  (set-foreground-color "ivory")
 
 

 
(set-terminal-coding-system 'latin-1)
(set-keyboard-coding-system 'latin-1)
(set-language-environment 'latin-1)


(setq-default \C-basi\C-offset 4)
  (setq tab-width 4)
  ;;(setq-default indent-tabs-mode nil)
 
 

(custom-set-variables
   ;; custom-set-variables was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
  '(cua-mode t nil (cua-base))
  '(current-language-environment "French")
  '(scroll-bar-mode nil)
  '(tool-bar-mode nil))
 
 (custom-set-faces
   ;; custom-set-faces was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
  '(default ((t (:inherit nil :stipple nil :background "grey5" :foreground "ivory" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "Droid Sans Mono"))))
  '(font-lock-comment-face ((nil (:foreground "#9EDCF6" :slant italic :height 0.9)))))
 
